#include "ConfigManager.h"

CConfigManager* CConfigManager::m_pInstance = nullptr;
CConfigManager::CConfigManager()
{
}

CConfigManager::~CConfigManager()
{
}

CConfigManager* CConfigManager::getInstance()
{
	if (!m_pInstance)
	{
		m_pInstance = new CConfigManager();
	}
	return m_pInstance;
}

void CConfigManager::destroy()
{
	CC_SAFE_DELETE(m_pInstance);
}

CConfigManagerBase* CConfigManager::getData(const string& strKey)
{
	map<string, CConfigManagerBase*>::iterator iter = m_mapManager.find(strKey);
	if (iter != m_mapManager.end())
	{
		return iter->second;
	}
	return nullptr;
}

void CConfigManager::setData(string strKey, CConfigManagerBase* pManager)
{
	if (strKey.empty() || !pManager)
	{
		return;
	}
	m_mapManager.insert(pair<string, CConfigManagerBase*>(strKey, pManager));
}
